package com.powernode.springmvc.controller;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ApplicationScopeTestController {

    @RequestMapping("/testApplicationServletAPI")
    public String testApplicationServletAPI(HttpServletRequest request){
        //将数据存储到application域当中
        //获取application对象，其实就是获取ServletContext对象
        //怎么获取ServletContext对象？通过request,session都可以
        ServletContext application = request.getServletContext();
        application.setAttribute("testApplicationScope","在SpringMVC中使用ServletAPI实现application域共享");
        return "ok";
    }
}
